<template>
      <el-container class="section pdbot_none">
        <el-main>
          <el-container>
            <el-main class="relative clear_padding">
              <gridPage 
                ref="grid" 
                :config="gridConfig" 
                @celick="celick" />
            </el-main>
            <el-aside class="relative side_width">
              <el-container>
                <el-header class="height_auto pdbt" style="text-align: center">
                  属性信息 - {{ opt }}
                </el-header>
                <el-main class="padding_top maxheigt has_pd_rg">
                    <form-panel
                        ref="myForm"
                        templet="DEV_FIELD_EDIT"
                        form-type="edit"
                        form-cols="1"
                        :data="mangerformdata"
                        :buttons="mangerformbuttons"
                    />
                </el-main>
              </el-container>
            </el-aside>
          </el-container>
        </el-main>
      </el-container>
</template>

<script>
import gridPage from '@/components/TablePage/gridPage2';
import request from '@/utils/requestutil'
import formPanel from '@/components/formpanel';
export default {
  components: {
    formPanel,
    gridPage,
  },
  data() {
    return {
        opt: '新增',
        code: '',
        mangerformbuttons: ['save'],
        mangerformdata: {},
        gridConfig: {
            settings: {
                height: '100%',
                maxHeight: '100%',
                templet:'DEV_FIELD_QUERY',
                queryTemplet:'DEV_FIELD_QUERY',
                queryFormCols: '4',
                // flag:'DEV_FIELD_QUERY',
            },
            odel: '',
            options: {
            treeConfigKey: '',
            checkType: 'check', // check // no
            isEdit: false, // 是否行内编辑
            isIndex: true, // 是否有索引
            isSort: false, // 是否拖拽排序
            tableToolbar: {
                refresh: true,//刷新
                zoom: true,//放大框
                export:true,
                tools: [
                    {
                        code: 'exportWord_slot',
                        name: '导出',
                        // icon: 'fa fa-cloud-download',
                        handler: this.export
                    }
                ],
                buttons: [
                    {
                        code: "btnDemo1",
                        name: "新建",
                        handler: this.addNew

                    },
                    {
                        code: "btnDemo2",
                        name: "删除",
                        handler: this.mydelete
                    },
                    {
                        code: "btnDemo2",
                        name: "发布"
                    }
                ]
            }
            }
      },
      searchParam: {
        id: '',
      },
    }
  },
  created() {
  },
  mounted(){
  },
  props:{
    myDetails: {
      type: Object,
      default: () => {},
    },
  },
  watch: {
    myDetails: {
      handler(val) {
        if (!val || !val.id)
          return
        this.$nextTick(() => {
          this.searchParam.id = val.id + ""
        //   this.commondFlag = 'NEW'
        //   this.$refs.editmngform.setData({tiIFcd:val.tiIFcd + "",bzcode:val.bzcode + "",tiISts:"C",tiIIsTag:"0"}, 'NEW')
          this.seachTable()
        })
      },
      deep: true,
      immediate: true,
    },
  },
  methods: {
    //删除
    mydelete(i, n){
      const nid = n.id
      const name = n.name
      this.$confirm('您确认删除【' + name + '】机构，是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        request({
          url: 'judgeSubUnitMore',
          method: 'post',
          params: { NID: nid }
        }).then(res => {
          if (res.success) {
            that.$message.success('删除成功')
            // 刷新
          } else {
            that.$message.error('删除失败')
          }
        })
      })
    },
    // 新增
    addNew() {
      const t = this
      t.opt = '新增'
      t.mangerformdata = {
      }
      t.mangerformdata.tableId = this.searchParam.id
      t.mangerformdata.code = 'ACC'
      t.$refs.myForm.setCommand('NEW')
    },
    // 编辑
    celick(val) {
      this.opt = '编辑'
      this.flag = 'edit'
      this.mangerformdata = val
      this.mangerformdata.code = val.fieldCode
      this.mangerformdata.tableId = this.searchParam.id
      this.$refs.myForm.setCommand('UPDATE')
    //   this.$refs.myForm.setData = {}
    },
    seachTable() {
      debugger
      let params = {}
      params.tableId = this.searchParam.id + ""
      params.orderField = "tableId"
      params.order =  "asc"
      this.$refs.grid.queryData(params)
      return
    }
  }
};
</script>
<style scoped>
</style>